﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace YXH_Tools_Files.Tools_Error
{
    public static class LogErrorMessage
    {
        /// <summary>
        /// 把error输出到logerror.txt
        /// </summary>
        /// <param name="file"></param>
        /// <param name="ex"></param>
        public static void getErrormessage(string file, string message)
        {
            var content = "处理此路径文件：" + file + "发生了错误：" + message;
            string path = Assembly.GetExecutingAssembly().Location;
            
            string? directory = Path.GetDirectoryName(path);
            if (!String.IsNullOrEmpty(directory))
            {
                string writepath = Path.Combine(directory, "logerror.txt");
                File.AppendAllText(writepath, content);
            }
            throw new Exception(message);
        }
    }
}
